package com.sdut.material.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.sdut.material.pojo.Permission;
import com.sdut.material.mapper.PermissionMapper;
import com.sdut.material.pojo.vo.LayUISelectMVO;
import com.sdut.material.service.IPermissionService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author Yu
 * @since 2022-04-20
 */
@Service
public class PermissionServiceImpl extends ServiceImpl<PermissionMapper, Permission> implements IPermissionService {
    @Autowired
    private PermissionMapper permissionMapper;
    @Override
    public List<LayUISelectMVO> selectAllPermissions() {
        List<Permission> permissionList = permissionMapper.selectList(new QueryWrapper<>());
        List<LayUISelectMVO> layUISelectMVOList = new ArrayList<>();
        for (Permission permission : permissionList) {
            LayUISelectMVO layUISelectMVO = new LayUISelectMVO();
            layUISelectMVO.setId(permission.getId());
            layUISelectMVO.setName(permission.getName());
            layUISelectMVO.setStatus(1);
            layUISelectMVOList.add(layUISelectMVO);
        }
        return layUISelectMVOList;
    }
}
